-
Notifications
You must be signed in to change notification settings - Fork 6
Add always flag to add_on_update_callback
#311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #311 +/- ##
=======================================
Coverage 90.78% 90.79%
=======================================
Files 70 70
Lines 2540 2542 +2
=======================================
+ Hits 2306 2308 +2
Misses 234 234 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
always flag to add_on_update_callback
|
Tested with @dataclass
class BitGroupOnUpdate:
"""Bits are tied together in bit groups so that when one is set for capture,
they all are.
This callback sets all capture attributes in the group when one of them is set.
"""
capture_attribute: AttrRW[enum.Enum]
bit_attributes: list[AttrRW[bool]]
async def __call__(self, value: Any):
if isinstance(value, enum.Enum):
bool_value = bool(self.capture_attribute.datatype.index_of(value)) # type: ignore
enum_value = value
else:
bool_value = value
assert isinstance(self.capture_attribute.datatype, Enum)
enum_value = self.capture_attribute.datatype.members[int(value)]
await asyncio.gather(
*(bit_attr.update(bool_value) for bit_attr in self.bit_attributes),
self.capture_attribute.update(enum_value),
)removing the need for: async def _set_attr_if_not_already_value(attribute: AttrRW[DType_T], value: DType_T):
if attribute.get() != value:
await attribute.update(value)So, this PR will be updated to close #133, as well. |
|
Could we add a simple check to this test rather than (or as well as) relying on the pva transport? Just something simple like an |
closes #306 and closes #133
Adds an always flag to
add_on_update_callback, and checks this flag when deciding what callback to call inupdate.